Skip to content

fix(common): enforce the full SASL contract in streaming.env - #1805

Merged
guimoreirar merged 1 commit into
mainfrom
fix/streaming-sasl-contract
Aug 2, 2026
Merged

fix(common): enforce the full SASL contract in streaming.env#1805
guimoreirar merged 1 commit into
mainfrom
fix/streaming-sasl-contract

Conversation

@guimoreirar

Copy link
Copy Markdown
Member

Completes the SASL fail-fast contract raised across the midaz #1741 reviews (Gandalf 6th review — three remaining REDs).

Problem

lib-streaming fails closed at bootstrap on an incomplete SASL config, but the chart rendered fine for:

  1. SASL without TLS — mechanism + creds + STREAMING_TLS_ENABLED=false + STREAMING_SASL_ALLOW_PLAINTEXT=false.
  2. Invalid mechanism — e.g. GSSAPI (only PLAIN, SCRAM-SHA-256, SCRAM-SHA-512 are supported).
  3. useExistingSecret=true bypassing username validation — the Secret template is skipped, so STREAMING_SASL_USERNAME: "" shipped.

Fix

Move the SASL contract validation into streaming.env (the ConfigMap, which always renders — even with an external Secret). When a mechanism is set it must be supported, a username is required (a ConfigMap value, known at render regardless of the Secret source), and TLS must be on unless plaintext is explicitly opted into.

Validation

Scenario Result
SCRAM + user, TLS off, no plaintext ❌ SASL requires TLS
SCRAM + user, TLS off, plaintext opt-in ✅ renders
GSSAPI + user + TLS ❌ unsupported mechanism
SCRAM + TLS, no username ❌ username required (fires via ConfigMap, so useExistingSecret is covered)
SCRAM + user + TLS ✅ renders
no mechanism ✅ unaffected

helm lint passes. Negative assertions for the three scenarios (Ledger + CRM) land with the re-pin in #1741.

lib-streaming fails closed at bootstrap on an incomplete SASL config, but the chart only
validated the password (and username, in the Secret which is skipped for useExistingSecret).
Validate the whole contract in streaming.env — the ConfigMap, which ALWAYS renders, so it
covers the external-Secret case too. When a mechanism is set:
- it must be one of PLAIN, SCRAM-SHA-256, SCRAM-SHA-512 (reject e.g. GSSAPI);
- a username is required (configmap.STREAMING_SASL_USERNAME -> global), including with an
  existing Secret (username is a ConfigMap value, known at render);
- TLS must be on (STREAMING_TLS_ENABLED=true) unless plaintext SASL is explicitly opted into
  (STREAMING_SASL_ALLOW_PLAINTEXT=true).
Validated: TLS-off fails, GSSAPI fails, missing username fails, valid config + plaintext opt-in
render; no SASL is unaffected.
@guimoreirar
guimoreirar requested a review from a team as a code owner August 2, 2026 18:17
@github-actions github-actions Bot added the common label Aug 2, 2026
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 71f4668c-0c82-4504-988e-204a64eb0a01

📥 Commits

Reviewing files that changed from the base of the PR and between da00b84 and a368945.

📒 Files selected for processing (1)
  • charts/lerian-common/templates/_streaming.tpl

📝 Walkthrough

Walkthrough

The streaming template now validates configured SASL mechanisms, requires a username, and requires TLS unless plaintext SASL is explicitly enabled. Validation runs during ConfigMap rendering, including when an external Secret is used.

Changes

Streaming SASL validation

Layer / File(s) Summary
SASL configuration validation
charts/lerian-common/templates/_streaming.tpl
Rendering now fails for unsupported SASL mechanisms, missing usernames, or disabled TLS without explicit plaintext opt-in.

Possibly related PRs

  • LerianStudio/helm#1798: Both changes update _streaming.tpl with SASL configuration validation, including username requirements.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/streaming-sasl-contract

Comment @coderabbitai help to get the list of available commands.

@guimoreirar
guimoreirar merged commit 60d18c3 into main Aug 2, 2026
5 checks passed
@guimoreirar
guimoreirar deleted the fix/streaming-sasl-contract branch August 2, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant